import 'package:medito/constants/constants.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';

import 'package:medito/constants/icons/medito_icons.dart';
import 'package:medito/widgets/medito_huge_icon.dart';

class PlayPauseButtonWidget extends ConsumerWidget {
  const PlayPauseButtonWidget({
    super.key,
    this.iconSize = 72,
    required this.isPlaying,
    required this.onPlayPause,
  });

  final double iconSize;
  final bool isPlaying;
  final Function() onPlayPause;

  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return InkWell(
      onTap: onPlayPause,
      borderRadius: BorderRadius.circular(iconSize / 2),
      child: AnimatedCrossFade(
        firstChild: MeditoIcon(
          assetName: MeditoIcons.playSolid,
          size: iconSize,
          color: ColorConstants.white,
        ),
        secondChild: MeditoIcon(
          assetName: MeditoIcons.pause,
          size: iconSize,
          color: ColorConstants.white,
        ),
        crossFadeState:
            isPlaying ? CrossFadeState.showSecond : CrossFadeState.showFirst,
        duration: const Duration(milliseconds: 100),
      ),
    );
  }
}
